$(function(){
	$sou = $("#sou");
	var $abc=$("#abc");
	var line=0;
	$abc.css({
		'left':$sou.offset().left,
		'top':$sou.offset().top+34,
		'width':600
	});
	$(window).resize(function(){
		$abc.css({
			'left':$sou.offset().left,
			'top':$sou.offset().top+34,
			'width':600
		});		
	});
	$sou.keyup(function(e){
		$abc.show();
		if(e.keyCode==13){
			$abc.hide();
		}
	});
	$sou.keydown(function(e){
		if(e.keyCode==40){
			if(line >= $("#abc ul li").length){
				line=0;
			}		
			$("#abc ul li").css("background","#FFF");
			$("#abc ul li").eq(line).css("background","#E9E9E9");
			$sou.val($("#abc ul li").eq(line).text());
			line++;
		}
		if(e.keyCode==38){
			line--;
			$("#abc ul li").css("background","#FFF");
			$("#abc ul li").eq(line-1).css("background","#E9E9E9");
			$sou.val($("#abc ul li").eq(line).text());
			if(line <= 0){
				line=$("#abc ul li").length;
			}				
		}

	})
	$sou.blur(function(){
		$abc.hide();
	});
	$("#abc ul li").mouseover(function(){
		$sou.val($(this).text());
		$("#abc ul li").css("background","#FFF");
		$(this).css("background","#E9E9E9");		
		line = $(this).index()+1;
	});
});
